
def read():
    import os
    import sqlite3

    #输出学生对象的数据：

    # 创建数据库连接
    conn = sqlite3.connect('.db')

    # 创建游标
    cursor = conn.cursor()

    # 查询学生表中的数据
    cursor.execute("SELECT * FROM students")

    # 获取查询结果
    results = cursor.fetchall()

    # 遍历结果并打印属性
    for row in results:
        student = Students(row[1], row[2], row[3], row[4], row[5], row[6])
        print("姓名:", student.name)
        print("学号:", student.student_id)
        print("用户名:", student.username)
        print("密码:", student.password)
        print("密保问题:", student.security_question)
        print("性别:", student.gender)
        print("------------------------")

    # 关闭游标和连接
    cursor.close()
    conn.close()